﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _13_Action
{
    internal class Program
    {
        static void Main(string[] args)
        {
            #region 无参无返回值

            //定义委托=>定义委托变量=>定义方法=>绑定委托
            Action action = () => Console.WriteLine("[{0}] 无参无返回值的委托",DateTime.Now);
            //调用委托
            action.Invoke();

            #endregion

            #region 有参数无返回值=>一个参数

            //定义委托=>定义委托变量=>定义方法=>绑定委托
            Action<string> action1 = msg => Console.WriteLine("[{0}] 有参数无返回值的委托=>一个参数:{1}", DateTime.Now, msg);
            //调用委托
            action1.Invoke("Hello World");

            #endregion

            #region 有参数无返回值=>多个参数

            Action<string, string> action2 = (msg1, msg2) => Console.WriteLine("[{0}] 有参数无返回值的委托=>多个参数:{1} {2}", DateTime.Now, msg1, msg2);
            action2.Invoke("Hello", "World");
            

            #endregion


            Console.ReadKey();
        }
    }
}
